package impl

import (
	"gitee.com/shiwjlinux/arm/apps/host"
	"gitee.com/shiwjlinux/arm/apps/instance"
	"gitee.com/shiwjlinux/arm/conf"
	"gitee.com/shiwjlinux/arm/ioc"
	"github.com/rs/zerolog"
	"go.mongodb.org/mongo-driver/mongo"
)

var (
	_ instance.Service = (*Impl)(nil)
	_ ioc.Object       = (*Impl)(nil)
)

type Impl struct {
	// TODO: 频繁变化的数据存到mongoDB
	// db   *gorm.DB
	db     *mongo.Database
	host   host.Service
	logger *zerolog.Logger
}

func init() {
	// 注册服务
	ioc.Controller.Registry(instance.AppName, &Impl{})
}

func (i *Impl) Init() error {
	i.db = conf.C().MongoDB.GetDB()
	// i.host = ioc.Controller.Get(host.AppName).(host.Service)
	i.host = host.GetService()
	// i.logger = 	conf.C().Logger.GetLogger()
	i.logger = conf.C().Log.Logger()

	return nil
}
